<template>
<el-table :data="stulist" style="width: 100%;padding-top: 15px;">
    <el-table-column label="学号" min-width="200">
        <template slot-scope="scope">
            {{ scope.row.stu_no | orderNoFilter }}
        </template>
    </el-table-column>
    <el-table-column label="姓名" min-width="200">
        <template slot-scope="scope">
            {{ scope.row.stuname | orderNoFilter }}
        </template>
    </el-table-column>
        <el-table-column label="语文" width="195" align="center">
        <template slot-scope="scope">
            {{ scope.row.score1 | toThousandFilter }}
        </template>
    </el-table-column>
    </el-table-column>
        <el-table-column label="数学" width="195" align="center">
        <template slot-scope="scope">
            {{ scope.row.score2 | toThousandFilter }}
        </template>
    </el-table-column>
    </el-table-column>
        <el-table-column label="手工" width="195" align="center">
        <template slot-scope="scope">
            {{ scope.row.score3 | toThousandFilter }}
        </template>
    </el-table-column>
    <el-table-column label="Status" width="100" align="center">
        <template slot-scope="{row}">
            <el-tag :type="row.status | statusFilter">
                {{ row.status }}
            </el-tag>
        </template>
    </el-table-column>
</el-table>
</template>

<script>
import {
    getStudentList
} from '@/api/remote-search'

export default {
    filters: {
        statusFilter(status) {
            const statusMap = {
                success: 'success',
                pending: 'danger'
            }
            return statusMap[status]
        },
        orderNoFilter(str) {
            return str.substring(0, 30)
        }
    },
    data() {
        return {
            stulist: null
        }
    },
    created() {
        this.fetchData()
    },
    methods: {
        fetchData() {
            getStudentList().then(response => {
                this.stulist = response.data.items.slice(0, 8)
            })
        }
    }
}
</script>
